package com.cnblogs.leizia.crm.configuration.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * 过滤器配置
 * @author leizi
 * @create 2021-02-15 16:39
 */
public class EncodingFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        // 设置请求编码
        request.setCharacterEncoding("utf-8");
        // 设置响应编码
        response.setContentType("text/html;charset=UTF-8");

        chain.doFilter(request,response);
    }

    @Override
    public void destroy() {

    }
}
